<template>
    <div class="cs">
        <NowPlaying class="slo">
            <div class="movie" v-for="item of movies" :key="item.pic" @click="handleJump(item._id)">
                <div class="left">
                    <img class="pic" :src="item.pic">
                    <div class="righttxt">
                        <p class="title">{{item.title}}</p>
                        <p class="rating">{{item.rating}}</p>
                    </div>
                </div>
                <div class="right">
                    购票
                </div>
            </div>
        </NowPlaying>
    </div>
</template>

<script>
import NowPlaying from '../../components/NowPlaying'
import axios from 'axios';
    export default {
        data(){
            return {
                movies:[]
            }
        },
        components:{
            NowPlaying
        },
        mounted(){
            let url = "http://47.108.197.28:4000/api/movie/comingSoon";
            axios.get(url).then(res=>{
            this.movies = res.data.res;
        })
    },
    methods:{
        handleStar(ele){
        var arr=[];
        for(let i=0;i<5;i++){
            if(ele>=2){
            arr.push(2)
            }else if(ele>=0){
            arr.push(Number(ele.toFixed(1)))
            }else{
            arr.push(0)
            }
            ele = ele - 2;
        }
        return arr
        },
        handleJump(id){
            console.log(id)
            this.$router.push(`/film/${id}`)
        }
    }
}
</script>

<style scoped>
</style>